package com.fc.primary.sort;

import java.util.Random;

/**
 * @program: fc-java->Mp
 * @description:
 * @author: G_Y
 * @create: 2019-09-02 14:33
 **/
public class Mp {

    private static int[] arr = new int[50];
    private static int len = arr.length;

    static {
        Random r = new Random();
        for (int i = 0; i < 50; i++) {
            arr[i] = r.nextInt(100);
        }
        p();
    }

    public static void main(String[] args) {
        f();
    }

    public static void f() {
        // 最外层确定循环次数
        for (int i = 0; i < len - 1; i++) {
            // 内层确定两两比较次数
            for (int j = 0; j < len - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    arr[j] = (arr[j] + arr[j + 1]) - (arr[j + 1] = arr[j]);
                }
            }
        }
        System.out.println("---------------------------------");
        p();
    }


    public static void p() {
        for (int a : arr) {
            System.out.print(a + " ");
        }
    }
}
